try!(cx.probe_target_info(&units));
for unit in units.iter() {
- let layout = cx.layout(&unit.pkg, unit.kind);
+ let layout = cx.layout(unit);
try!(rm_rf(&layout.proxy().fingerprint(&unit.pkg)));
try!(rm_rf(&layout.build(&unit.pkg)));
/// Prepare this context, ensuring that all filesystem directories are in
/// place.
- pub fn prepare(&mut self, root: &Package) -> CargoResult<()> {
+ pub fn prepare(&mut self) -> CargoResult<()> {
let _p = profile::start("preparing layout");
try!(self.host.prepare().chain_error(|| {
None => {}
}
- self.compilation.root_output =
- self.layout(root, Kind::Target).proxy().dest().to_path_buf();
- self.compilation.deps_output =
- self.layout(root, Kind::Target).proxy().deps().to_path_buf();
+ let layout = self.target.as_ref().unwrap_or(&self.host);
+ self.compilation.root_output = layout.dest().to_path_buf();
+ self.compilation.deps_output = layout.deps().to_path_buf();
Ok(())
}
}
/// Returns the appropriate directory layout for either a plugin or not.
- pub fn layout(&self, pkg: &Package, kind: Kind) -> LayoutProxy {
- let primary = pkg.package_id() == self.resolve.root();
- match kind {
+ pub fn layout(&self, unit: &Unit) -> LayoutProxy {
+ let primary = unit.pkg.package_id() == self.resolve.root();
+ match unit.kind {
Kind::Host => LayoutProxy::new(&self.host, primary),
Kind::Target => LayoutProxy::new(self.target.as_ref()
.unwrap_or(&self.host),
}
}
+ /// Returns the path for plugin/dylib dependencies
+ pub fn host_dylib_path(&self) -> &Path {
+ self.host.deps()
+ }
+
/// Returns the appropriate output directory for the specified package and
/// target.
pub fn out_dir(&self, unit: &Unit) -> PathBuf {
if unit.profile.doc {
- self.layout(unit.pkg, unit.kind).doc_root()
+ self.layout(unit).doc_root()
} else {
- self.layout(unit.pkg, unit.kind).out_dir(unit.pkg, unit.target)
+ self.layout(unit).out_dir(unit)
}
}
let mut metadata = unit.pkg.generate_metadata();
metadata.mix(&format!("bin-{}", unit.target.name()));
Some(metadata)
- } else if unit.pkg.package_id() == self.resolve.root() &&
+ } else if unit.pkg.package_id().source_id().is_path() &&
!unit.profile.test {
// If we're not building a unit test then the root package never
// needs any metadata as it's guaranteed to not conflict with any
fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>)
-> CargoResult<(Work, Work)> {
+ let host_unit = Unit { kind: Kind::Host, ..*unit };
let (script_output, build_output) = {
- (cx.layout(unit.pkg, Kind::Host).build(unit.pkg),
- cx.layout(unit.pkg, unit.kind).build_out(unit.pkg))
+ (cx.layout(&host_unit).build(unit.pkg),
+ cx.layout(unit).build_out(unit.pkg))
};
// Building the command to execute
};
cx.build_explicit_deps.insert(*unit, (output_file.clone(), rerun_if_changed));
- try!(fs::create_dir_all(&cx.layout(unit.pkg, Kind::Host).build(unit.pkg)));
- try!(fs::create_dir_all(&cx.layout(unit.pkg, unit.kind).build(unit.pkg)));
+ try!(fs::create_dir_all(&cx.layout(&host_unit).build(unit.pkg)));
+ try!(fs::create_dir_all(&cx.layout(unit).build(unit.pkg)));
// Prepare the unit of "dirty work" which will actually run the custom build
// command.
/// Return the (old, new) location for fingerprints for a package
pub fn dir(cx: &Context, unit: &Unit) -> PathBuf {
- cx.layout(unit.pkg, unit.kind).proxy().fingerprint(unit.pkg)
+ cx.layout(unit).proxy().fingerprint(unit.pkg)
}
/// Returns the (old, new) location for the dep info file of a target.
use std::io;
use std::path::{PathBuf, Path};
-use core::{Package, Target, Workspace};
+use core::{Package, Workspace};
use util::{Config, FileLock, CargoResult, Filesystem};
use util::hex::short_hash;
+use super::Unit;
pub struct Layout {
root: PathBuf,
pub fn proxy(&self) -> &'a Layout { self.root }
- pub fn out_dir(&self, pkg: &Package, target: &Target) -> PathBuf {
- if target.is_custom_build() {
- self.build(pkg)
- } else if target.is_example() {
+ pub fn out_dir(&self, unit: &Unit) -> PathBuf {
+ if unit.target.is_custom_build() {
+ self.build(unit.pkg)
+ } else if unit.target.is_example() {
self.examples().to_path_buf()
+ } else if unit.target.is_lib() {
+ self.deps().to_path_buf()
} else {
self.root().to_path_buf()
}
let mut queue = JobQueue::new(&cx);
- try!(cx.prepare(root));
+ try!(cx.prepare());
try!(cx.probe_target_info(&units));
try!(custom_build::build_map(&mut cx, &units));
try!(queue.execute(&mut cx));
for unit in units.iter() {
- let out_dir = cx.layout(unit.pkg, unit.kind).build_out(unit.pkg)
+ let out_dir = cx.layout(unit).build_out(unit.pkg)
.display().to_string();
cx.compilation.extra_env.entry(unit.pkg.package_id().clone())
.or_insert(Vec::new())
let do_rename = unit.target.allows_underscores() && !unit.profile.test;
let real_name = unit.target.name().to_string();
let crate_name = unit.target.crate_name();
+ let move_outputs_up = unit.pkg.package_id() == cx.resolve.root();
let rustc_dep_info_loc = if do_rename {
root.join(&crate_name)
let src = dst.with_file_name(dst.file_name().unwrap()
.to_str().unwrap()
.replace(&real_name, &crate_name));
- if !has_custom_args || fs::metadata(&src).is_ok() {
+ if !has_custom_args || src.exists() {
try!(fs::rename(&src, &dst).chain_error(|| {
internal(format!("could not rename crate {:?}", src))
}));
try!(fingerprint::append_current_dir(&dep_info_loc, &cwd));
}
+ // If we're a "root crate", e.g. the target of this compilation, then we
+ // hard link our outputs out of the `deps` directory into the directory
+ // above. This means that `cargo build` will produce binaries in
+ // `target/debug` which one probably expects.
+ if move_outputs_up {
+ for &(ref filename, _linkable) in filenames.iter() {
+ let src = root.join(filename);
+ // This may have been a `cargo rustc` command which changes the
+ // output, so the source may not actually exist.
+ if !src.exists() {
+ continue
+ }
+
+ // We currently only lift files up from the `deps` directory. If
+ // it was compiled into something like `example/` or `doc/` then
+ // we don't want to link it up.
+ let src_dir = src.parent().unwrap();
+ if !src_dir.ends_with("deps") {
+ continue
+ }
+ let dst = src_dir.parent().unwrap()
+ .join(src.file_name().unwrap());
+ if dst.exists() {
+ try!(fs::remove_file(&dst).chain_error(|| {
+ human(format!("failed to remove: {}", dst.display()))
+ }));
+ }
+ try!(fs::hard_link(&src, &dst).chain_error(|| {
+ human(format!("failed to link `{}` to `{}`",
+ src.display(), dst.display()))
+ }));
+ }
+ }
+
Ok(())
}));
try!(build_deps_args(&mut rustdoc, cx, unit));
if unit.pkg.has_custom_build() {
- rustdoc.env("OUT_DIR", &cx.layout(unit.pkg, unit.kind)
- .build_out(unit.pkg));
+ rustdoc.env("OUT_DIR", &cx.layout(unit).build_out(unit.pkg));
}
rustdoc.args(&try!(cx.rustdocflags_args(unit)));
fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
-> CargoResult<()> {
- let layout = cx.layout(unit.pkg, unit.kind);
- cmd.arg("-L").arg(&{
- let mut root = OsString::from("dependency=");
- root.push(layout.root());
- root
- });
+ let layout = cx.layout(unit);
cmd.arg("-L").arg(&{
let mut deps = OsString::from("dependency=");
deps.push(layout.deps());
}
for unit in try!(cx.dep_targets(unit)).iter() {
- if unit.target.linkable() {
+ if unit.target.linkable() && !unit.profile.doc {
try!(link_to(cmd, cx, unit));
}
}
fn link_to(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
-> CargoResult<()> {
- let layout = cx.layout(unit.pkg, unit.kind);
-
for (filename, linkable) in try!(cx.target_filenames(unit)) {
if !linkable {
continue
let mut v = OsString::new();
v.push(&unit.target.crate_name());
v.push("=");
- v.push(layout.root());
+ v.push(cx.out_dir(unit));
v.push(&path::MAIN_SEPARATOR.to_string());
v.push(&filename);
cmd.arg("--extern").arg(&v);
cx: &Context) -> CargoResult<CommandPrototype> {
// When invoking a tool, we need the *host* deps directory in the dynamic
// library search path for plugins and such which have dynamic dependencies.
- let layout = cx.layout(pkg, Kind::Host);
let mut search_path = util::dylib_path();
- search_path.push(layout.deps().to_path_buf());
+ search_path.push(cx.host_dylib_path().to_path_buf());
// We want to use the same environment and such as normal processes, but we
// want to override the dylib search path with the one we just calculated.
p.arg("--test").arg(lib)
.arg("--crate-name").arg(&crate_name);
- for &rust_dep in &[&compilation.deps_output, &compilation.root_output] {
+ for &rust_dep in &[&compilation.deps_output] {
let mut arg = OsString::from("dependency=");
arg.push(rust_dep);
p.arg("-L").arg(arg);
format!("\
[COMPILING] {name} v{version} ({url})
[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
- --out-dir {dir}{sep}target{sep}debug \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
[RUNNING] `rustc a[..]build.rs [..] --extern b=[..]`
[RUNNING] `[..]a-[..]build-script-build[..]`
[RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \
- -C metadata=[..] -C extra-filename=-[..] \
--out-dir [..]target[..]deps --emit=dep-info,link \
- -L [..]target[..]deps -L [..]target[..]deps`
+ -L [..]target[..]deps`
[COMPILING] foo v0.5.0 (file://[..])
[RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin \
- -g \
- --out-dir [..]build[..]foo-[..] --emit=dep-info,link \
- -L [..]target[..]debug -L [..]target[..]deps \
- --extern a=[..]liba-[..].rlib`
+ -g --out-dir [..] --emit=dep-info,link \
+ -L [..]target[..]deps \
+ --extern a=[..]liba[..].rlib`
[RUNNING] `[..]foo-[..]build-script-build[..]`
[RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \
- --out-dir [..]target[..]debug --emit=dep-info,link \
- -L [..]target[..]debug -L [..]target[..]deps`
+ --out-dir [..] --emit=dep-info,link \
+ -L [..]target[..]deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));
}
fn main() {
let src = PathBuf::from(env::var("SRC").unwrap());
- println!("cargo:rustc-link-search={}/target/debug",
+ println!("cargo:rustc-link-search={}/target/debug/deps",
src.display());
}
"#)
-C lto \
--out-dir {dir}[..]target[..]release \
--emit=dep-info,link \
- -L dependency={dir}[..]target[..]release \
-L dependency={dir}[..]target[..]release[..]deps`
[FINISHED] release [optimized] target(s) in [..]
",
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib -g \
- --out-dir {dir}[..]target[..]debug \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}[..]target[..]debug \
-L dependency={dir}[..]target[..]debug[..]deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
",
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \
-C opt-level=3 \
- --out-dir {dir}[..]target[..]release \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}[..]target[..]release \
-L dependency={dir}[..]target[..]release[..]deps`
[FINISHED] release [optimized] target(s) in [..]
",
[RUNNING] `rustc foo[..]src[..]lib.rs --crate-name foo \
--crate-type dylib --crate-type rlib -C prefer-dynamic \
-C opt-level=3 \
- -C metadata=[..] \
- -C extra-filename=-[..] \
- --out-dir {dir}[..]target[..]release[..]deps \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}[..]target[..]release[..]deps \
-L dependency={dir}[..]target[..]release[..]deps`
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \
-C opt-level=3 \
- --out-dir {dir}[..]target[..]release \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}[..]target[..]release \
-L dependency={dir}[..]target[..]release[..]deps \
--extern foo={dir}[..]target[..]release[..]deps[..]\
- {prefix}foo-[..]{suffix} \
- --extern foo={dir}[..]target[..]release[..]deps[..]libfoo-[..].rlib`
+ {prefix}foo{suffix} \
+ --extern foo={dir}[..]target[..]release[..]deps[..]libfoo.rlib`
[FINISHED] release [optimized] target(s) in [..]
",
dir = p.root().display(),
"#)
.file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("run"), execs().with_status(0));
+ assert_that(p.cargo_process("run").arg("-v"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
if cfg!(windows) {
// On windows unlinking immediately after running often fails, so sleep
sleep_ms(100);
}
fs::remove_file(&p.bin("foo")).unwrap();
- assert_that(p.cargo("run"),
+ assert_that(p.cargo("run").arg("-v"),
execs().with_status(0));
}
assert_that(p.cargo_process("build").arg("-v").arg("--color").arg("never"),
execs().with_status(0).with_stderr("\
[COMPILING] test v0.0.0 ([..])
-[RUNNING] `rustc src[..]lib.rs --color never --crate-name test --crate-type lib -g \
- --out-dir [..]target[..]debug \
- --emit=dep-info,link \
- -L dependency=[..]target[..]debug \
- -L dependency=[..]target[..]debug[..]deps`
+[RUNNING] `rustc [..] --color never [..]`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));
}
execs().with_status(0).
with_stderr_contains("[COMPILING] foo v0.5.0 [..]
[RUNNING] `rustc [..] --crate-name foo --crate-type \
-bin -g --out-dir [..] --emit=dep-info,link -L dependency=[..]\
--L dependency=[..]"));
+bin -g --out-dir [..] --emit=dep-info,link -L dependency=[..]"));
}
#[test]
--emit=dep-info,link \
--target {target} \
-C ar=my-ar-tool -C linker=my-linker-tool \
- -L dependency={dir}[..]target[..]{target}[..]debug \
-L dependency={dir}[..]target[..]{target}[..]debug[..]deps`
",
dir = p.root().display(),
fn main() {
let src = PathBuf::from(env::var("SRC").unwrap());
- println!("cargo:rustc-flags=-L {}", src.parent().unwrap()
+ println!("cargo:rustc-flags=-L {}/deps", src.parent().unwrap()
.display());
}
"#)
-C opt-level=1 \
-C debug-assertions=on \
-C rpath \
- --out-dir {dir}{sep}target{sep}debug \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [optimized] target(s) in [..]
", sep = SEP,
--crate-type dylib --crate-type rlib -C prefer-dynamic \
-C opt-level=1 \
-g \
- -C metadata=[..] \
- -C extra-filename=-[..] \
--out-dir {dir}{sep}target{sep}release{sep}deps \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}release{sep}deps \
-L dependency={dir}{sep}target{sep}release{sep}deps`
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc src{sep}lib.rs --crate-name test --crate-type lib \
-C opt-level=1 \
-g \
- --out-dir {dir}{sep}target{sep}release \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}release \
-L dependency={dir}{sep}target{sep}release{sep}deps \
--extern foo={dir}{sep}target{sep}release{sep}deps{sep}\
- {prefix}foo-[..]{suffix} \
- --extern foo={dir}{sep}target{sep}release{sep}deps{sep}libfoo-[..].rlib`
+ {prefix}foo[..]{suffix} \
+ --extern foo={dir}{sep}target{sep}release{sep}deps{sep}libfoo.rlib`
[FINISHED] release [optimized + debuginfo] target(s) in [..]
",
dir = p.root().display(),
[COMPILING] bar v0.0.1 ({url}/bar)
[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
-C opt-level=3 \
- -C metadata=[..] \
- -C extra-filename=[..] \
--out-dir {dir}{sep}target{sep}release{sep}deps \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}release{sep}deps \
-L dependency={dir}{sep}target{sep}release{sep}deps`
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \
-C opt-level=3 \
--out-dir {dir}{sep}target{sep}release{sep}examples \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}release \
-L dependency={dir}{sep}target{sep}release{sep}deps \
- --extern bar={dir}{sep}target{sep}release{sep}deps{sep}libbar-[..].rlib`
+ --extern bar={dir}{sep}target{sep}release{sep}deps{sep}libbar.rlib`
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `target{sep}release{sep}examples{sep}a[..]`
",
[COMPILING] bar v0.0.1 ({url}/bar)
[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
-g \
- -C metadata=[..] \
- -C extra-filename=[..] \
--out-dir {dir}{sep}target{sep}debug{sep}deps \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug{sep}deps \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \
-g \
--out-dir {dir}{sep}target{sep}debug{sep}examples \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps \
- --extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar-[..].rlib`
+ --extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar.rlib`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `target{sep}debug{sep}examples{sep}a[..]`
",
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
- --out-dir {dir}{sep}target{sep}debug \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
-C debug-assertions=off \
- --out-dir {dir}{sep}target{sep}debug \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
.with_stderr(&format!("\
[COMPILING] {name} v{version} ({url})
[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
- --out-dir {dir}{sep}target{sep}debug \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[RUNNING] `rustc src{sep}main.rs --crate-name {name} --crate-type bin -g \
-C debug-assertions \
- --out-dir {dir}{sep}target{sep}debug \
+ --out-dir [..] \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps \
- --extern {name}={dir}{sep}target{sep}debug{sep}lib{name}.rlib`
+ --extern {name}={dir}{sep}target[..]lib{name}.rlib`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
dir = p.root().display(), url = p.url(),
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
- --out-dir {dir}{sep}target{sep}debug [..]`
+ --out-dir [..]`
[RUNNING] `rustc src{sep}bin{sep}bar.rs --crate-name bar --crate-type bin -g \
-C debug-assertions [..]`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
-", sep = SEP,
- dir = p.root().display(), url = p.url())));
+", sep = SEP, url = p.url())));
}
#[test]
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
- --out-dir {dir}{sep}target{sep}debug [..]`
+ --out-dir [..]`
[RUNNING] `rustc tests{sep}bar.rs --crate-name bar -g \
-C debug-assertions [..]--test[..]`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
-", sep = SEP,
- dir = p.root().display(), url = p.url())));
+", sep = SEP, url = p.url())));
}
#[test]
.with_status(0)
.with_stderr(format!("\
[COMPILING] bar v0.1.0 ([..])
-[RUNNING] `[..] -g -C [..]`
+[RUNNING] `[..] -g [..]`
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `[..] -g -C debug-assertions [..]`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[DOCUMENTING] foo v0.0.1 ({url})
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
-o {dir}{sep}target{sep}doc \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
-o {dir}{sep}target{sep}doc \
--no-defaults \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
-o {dir}{sep}target{sep}doc \
--no-defaults \
- -L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps \
--extern [..]`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `rustdoc [..]bar{sep}src{sep}lib.rs --crate-name bar \
-o {dir}{sep}target{sep}doc \
--no-defaults \
- -L dependency={dir}{sep}target{sep}debug{sep}deps \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
extern crate cargotest;
extern crate hamcrest;
-use std::io::Read;
+use std::io::{Read, Write};
use std::fs::File;
use cargotest::support::{project, execs};
assert_eq!(lockfile, lockfile2);
}
+
+#[test]
+fn rebuild_please() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [workspace]
+ members = ['lib', 'bin']
+ "#)
+ .file("lib/Cargo.toml", r#"
+ [package]
+ name = "lib"
+ version = "0.1.0"
+ "#)
+ .file("lib/src/lib.rs", r#"
+ pub fn foo() -> u32 { 0 }
+ "#)
+ .file("bin/Cargo.toml", r#"
+ [package]
+ name = "bin"
+ version = "0.1.0"
+
+ [dependencies]
+ lib = { path = "../lib" }
+ "#)
+ .file("bin/src/main.rs", r#"
+ extern crate lib;
+
+ fn main() {
+ assert_eq!(lib::foo(), 0);
+ }
+ "#);
+ p.build();
+
+ assert_that(p.cargo("run").cwd(p.root().join("bin")),
+ execs().with_status(0));
+
+ t!(t!(File::create(p.root().join("lib/src/lib.rs"))).write_all(br#"
+ pub fn foo() -> u32 { 1 }
+ "#));
+
+ assert_that(p.cargo("build").cwd(p.root().join("lib")),
+ execs().with_status(0));
+
+ assert_that(p.cargo("run").cwd(p.root().join("bin")),
+ execs().with_status(101));
+}